
#coding:utf-8
'''

@author: author
'''
import sys
sys = sys
if sys.getdefaultencoding() != 'utf-8':
    reload(sys)
    sys.setdefaultencoding('utf-8')
    

from flask.app import Flask
from flask_restful import Api
from logging.config import dictConfig

from flask_sqlalchemy import SQLAlchemy
from flask_redis import FlaskRedis
from flask_admin import Admin
from flask_babelex import Babel
from flask_login.login_manager import LoginManager
from flask_peewee.db import Database


dictConfig({
    'version': 1,
    'formatters': {'default': {
        'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s',
    }},
    'handlers': {'wsgi': {
        'class': 'logging.StreamHandler',
        'stream': sys.stdout,
        'formatter': 'default'
    }},
    'root': {
        'level': 'INFO',
        'handlers': ['wsgi']
    }
})


app = Flask(__name__, instance_relative_config=True)

app.config.from_pyfile('config.py') # 从instance文件夹中加载配置
app.config.from_object('config.%s'%app.config["RUN_MODEL"])#读取指定配置

api = Api(app)
db=SQLAlchemy(app)

# database = Database(app)
cache = FlaskRedis(app)
babel = Babel(app)
login_manager = LoginManager(app)
